let {Global} = require('Global')

cc.Class({
    extends: cc.Component,
    properties: {
        alreadyBetRate: {
            set(newValue) {
                let rate = newValue
                if (!rate) rate = 1
                let baseBetMoney = Global.room.baseBetMoney
                let leftRate = (Global.user.gold + baseBetMoney * rate) / (rate * baseBetMoney)
                console.log(`${Global.user.gold}, ${baseBetMoney}, ${leftRate}`)
                this.menus.forEach((item, idx) => {
                    item.enable = idx + 1 <= leftRate
                    item.getComponent(cc.Sprite).spriteFrame = item.enable ? this.sprites[1] : this.sprites[0]
                })
            }
        },

        menus: {
            default: [],
            type: cc.Button
        },

        sprites: {
            default: [],
            type: cc.SpriteFrame
        }


    }

})